---
title: Distribute a letter or report
summary: Builds (if needed) and distributes a report/letter's XML via clsPrint.
status: draft
owner: SAIF Case Management
last_reviewed: 2026-08-21
library: SAIF.Services.Printing
reference_type: embedded
operation_id: OP-REPORTING-DISTRIBUTE
trigger: Caller invokes Reporting.ReportBase.Distribute
---

# Distribute a letter or report

Ensures a report/letter's XML has been built, then distributes it as plain XML string content via the internally owned `clsPrint` instance.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-REPORTING-DISTRIBUTE |
| **Trigger** | Caller invokes `Reporting.ReportBase.Distribute(overwrite)` |
| **Inputs** | `overwrite` flag |
| **Outputs** | Boolean success flag |
| **Primary components** | `Reporting.ReportBase.Distribute` |
| **Entry point** | `SAIF.Services.Printing\Reporting\ReportBase.vb` |

## Steps

1. If no rendered file exists (or `overwrite` requested), calls `Create(overwrite)` directly — note: unlike [Print a letter or report](print-report.md), this calls `Create` directly rather than [Render a letter or report](render-report.md), so the XML is (re)built but not necessarily re-rendered to bytes first.*
2. If `m_reportXml` is not `Nothing` and `ReportPackage` is non-empty, calls `xPrint.distributeDocument(m_ReportPackage, m_reportXml.ToString)` — delegates to [Distribute a document](distribute-document.md) — sending the report as plain XML (`ToString`), rather than the xPression markup (`ToXpression`) used by [Render a letter or report](render-report.md).*
   - On failure: exception is caught (see step 3).
3. Exceptions are caught and recorded as an `ErrorDetail`; returns `True` only on success.

## Process flow

```mermaid
flowchart TD
	Start([Distribute called]) --> Check{Rendered file exists and not overwrite?}
	Check -->|No| Create[Call Create directly]
	Check -->|Yes| HasXml[XML already available]
	Create --> HasXml2{m_reportXml not Nothing and ReportPackage non-empty?}
	HasXml2 -->|No| EndFail([Return False, no distribution])
	HasXml2 -->|Yes| Distribute[Call xPrint.distributeDocument with plain XML string]
	HasXml --> Distribute
	Distribute --> EndOk([Return True])
	Distribute -->|Exception| Error[Record ErrorDetail]
```

## Failure and edge-case behavior
- Exceptions during distribution are caught and recorded as an `ErrorDetail`; the method returns `True` only on success.
- A discrepancy exists between this operation sending `m_reportXml.ToString()` (plain XML) versus [Render a letter or report](render-report.md) sending `m_reportXml.ToXpression` (custom xPression markup) to the same downstream `clsPrint` operations — this could be intentional (different consumers) or a latent inconsistency; not confirmable from this library's code alone.**

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `SAIF.Services.Printing\Reporting\ReportBase.vb`
